package nl.rainbowsheep.reisorg.rest.service.controller.helper;

import java.util.Random;

/**
 * This class generates a random password
 */
public class RandomPasswordGenerator {
    /**
     * This method randomly generates a new string which will be used for resetting the password
     * @param length
     * @return new passwordstring
     */
    public static String getRandomString(int length) {
       final String characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJLMNOPQRSTUVWXYZ1234567890!@#$%^&*()_+";
       StringBuilder result = new StringBuilder();
       Random rand = new Random();
       while(length > 0) {
           result.append(characters.charAt(rand.nextInt(characters.length())));
           length--;
       }
       return result.toString();
    }
}
